package kamikazehero.library;
import java.io.File;
import java.io.IOException;

import kamikazehero.constants.Constants;

public class Loader {
	
	//JInput Windows Library
	
	private File _PATH_JI_RAW_WIN = new File("jinput-raw.dll");
	private File _PATH_JI_DX8_WIN = new File("/jinput-dx8.dll");
	private String location;
	
	public Loader(){	
		location = this.getPath();
		this.load();
	}
	
	private String getPath(){
		String path = null;
		try {
			path = new File(".").getCanonicalPath();
		} catch (IOException e) {
			e.printStackTrace();
		}

		//path.concat("\\");
	
		return path;
	}
	
	private void load(){
		String osName = System.getProperty("os.name");
	    try {
	    	if (osName.startsWith("Mac OS")) {
	    		System.load(location + Constants._PATH_JI_OSX);
	        } else if(osName.startsWith("Windows")){
	    		System.load(location + Constants._PATH_JI_DX8_WIN);
	    		System.load(location + Constants._PATH_JI_RAW_WIN);
	        } else {
	        	
	        }  
	    }catch (Exception e) {
	    	e.printStackTrace();
	    }
	}
	
}
